/********************************************************************************
*
* File: pcat.lex
* The PCAT scanner
*
********************************************************************************/

import java_cup.runtime.Symbol;

%%
%class PcatLex
%public
%line
%char
%cup
%state comment

%{
  public int line_pos () { return yyline+1; }

  public int char_pos () { return yychar; }

  public static Symbol symbol ( int s ) {
    Ast.line_number = PcatParser.scanner.line_pos();
    Ast.position_number = PcatParser.scanner.char_pos();
    return new Symbol(s);
  }

  public static Symbol symbol ( int s, Object o ) {
    Ast.line_number = PcatParser.scanner.line_pos();
    Ast.position_number = PcatParser.scanner.char_pos();
    return new Symbol(s,o);
  }

  public void lexical_error ( String message ) {
    System.err.println("*** Lexical Error: " + message + " (line: " + line_pos()
		       + ", position: " + char_pos() + ")");
    System.exit(1);
  }
%}

%%

"BEGIN"		{ return symbol(sym.BEGIN); }
.		{ lexical_error("Illegal character"); }
